/**
 * 内容脚本样式
 * 用于页面内翻译结果的样式
 */

/* 翻译容器基础样式 */
.translator-container {
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
    border: 1px solid #e1e5e9;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

.translator-section {
    width: 100%;
}

/* 翻译头部样式 */
.translator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    min-height: 48px;
}

.translator-label {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
    display: flex;
    align-items: center;
}

.translator-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.translator-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.translator-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.translator-btn:active {
    transform: translateY(0);
}

.toggle-btn {
    min-width: 32px;
    padding: 6px 8px;
    font-weight: bold;
}

/* 翻译内容区域 */
.translator-content {
    padding: 16px;
    background: white;
}

.translator-content-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 原文和译文区块 */
.translator-original,
.translator-translated {
    margin-bottom: 12px;
}

.translator-original:last-child,
.translator-translated:last-child {
    margin-bottom: 0;
}

.translator-original h4,
.translator-translated h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.translator-original > div,
.translator-translated > div {
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.translator-original > div {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #495057;
}

.translator-translated > div {
    background: #e8f5e8;
    border: 1px solid #c3e6cb;
    color: #155724;
}

/* 并排模式特殊样式 */
.translator-side-mode .translator-original > div,
.translator-side-mode .translator-translated > div {
    min-height: 60px;
}

/* 替换模式样式 */
.translator-replace-container {
    margin: 0;
}

.translator-replace-container .translator-content {
    padding: 16px;
}

.translator-replace-container .translator-original > div,
.translator-replace-container .translator-translated > div {
    background: white;
    border: 1px solid #dee2e6;
    color: #212529;
    margin: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .translator-content-side {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .translator-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .translator-actions {
        align-self: stretch;
        justify-content: space-between;
    }

    .translator-btn {
        font-size: 11px;
        padding: 4px 8px;
    }

    .translator-content {
        padding: 12px;
    }

    .translator-original > div,
    .translator-translated > div {
        padding: 10px;
        font-size: 13px;
    }
}

/* 深色主题适配 */
@media (prefers-color-scheme: dark) {
    .translator-container {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .translator-header {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
        border-color: #4a5568;
    }

    .translator-label {
        color: #e2e8f0;
    }

    .translator-btn {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .translator-btn:hover {
        background: #718096;
        border-color: #a0aec0;
    }

    .translator-original > div {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }

    .translator-translated > div {
        background: #2f855a;
        border-color: #38a169;
        color: #f0fff4;
    }

    .translator-original h4,
    .translator-translated h4 {
        color: #a0aec0;
    }
}

/* Codeforces 特定样式适配 */
html[data-site="codeforces"] .translator-container {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html[data-site="codeforces"] .translator-label {
    color: #3b5998;
}

html[data-site="codeforces"] .translator-translated > div {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1565c0;
}

/* AtCoder 特定样式适配 */
html[data-site="atcoder"] .translator-container {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}

html[data-site="atcoder"] .translator-label {
    color: #0054a6;
}

html[data-site="atcoder"] .translator-translated > div {
    background: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

/* 动画效果 */
.translator-container {
    animation: translatorSlideIn 0.3s ease-out;
}

@keyframes translatorSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滚动条样式 */
.translator-original > div::-webkit-scrollbar,
.translator-translated > div::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.translator-original > div::-webkit-scrollbar-track,
.translator-translated > div::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.translator-original > div::-webkit-scrollbar-thumb,
.translator-translated > div::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.translator-original > div::-webkit-scrollbar-thumb:hover,
.translator-translated > div::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 代码块样式 */
.translator-original pre,
.translator-translated pre {
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.45;
    margin: 8px 0;
}

.translator-translated pre {
    background: #f0fff4;
    border-color: #c3e6cb;
}

/* 高亮效果 */
.translator-container:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.2s ease;
}

/* 折叠动画 */
.translator-content.collapsing {
    transition: max-height 0.3s ease-out;
    overflow: hidden;
}

/* 复制成功提示 */
.translator-copy-success {
    position: relative;
}

.translator-copy-success::after {
    content: '✓ 已复制';
    position: absolute;
    top: -30px;
    right: 0;
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    pointer-events: none;
}

.translator-copy-success.show::after {
    opacity: 1;
    transform: translateY(0);
}

/* 加载状态 */
.translator-loading {
    opacity: 0.6;
    pointer-events: none;
}

.translator-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1;
}

.translator-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: translatorSpin 1s linear infinite;
    z-index: 2;
}

@keyframes translatorSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误状态 */
.translator-error {
    background: #fff5f5;
    border-color: #fed7d7;
    color: #c53030;
}

.translator-error .translator-label {
    color: #c53030;
}

/* 紧凑模式 */
.translator-compact .translator-header {
    padding: 8px 12px;
}

.translator-compact .translator-content {
    padding: 12px;
}

.translator-compact .translator-btn {
    padding: 4px 8px;
    font-size: 11px;
}

/* 打印样式 */
@media print {
    .translator-container {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .translator-header {
        background: #f5f5f5 !important;
    }

    .translator-actions {
        display: none;
    }

    .translator-content-side {
        display: block;
    }

    .translator-original,
    .translator-translated {
        margin-bottom: 8px;
    }
}